<%-- 
    Document   : db1
    Created on : 2014/8/19, 下午 01:26:17
    Author     : gjun
--%>

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    //要連資料庫，先載入jar檔(MySQL JDBC Driver)
    Class.forName("com.mysql.jdbc.Driver");         //載入驅動程式(資料庫的Driver Class)
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb", "root", "root");  //連線資料庫(資料庫的Database URL、帳號、密碼)
    Statement st = con.createStatement();           //要輸入sql語法，需使用Statement物件
    String sql = "update person set username='John', tel='05-5555555' where id=3";  //修改，不用where指定會全改
    int x = st.executeUpdate(sql);                  //執行sql語法
    st.close();
    con.close();
    %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        處理了<%= x %>筆資料 <br>
    </body>
</html>
